package com.genITeam.ria.dao;

import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Logger;
import org.hibernate.Session;
import org.hibernate.criterion.Expression;

import com.genITeam.ria.exception.NGFException;
import com.genITeam.ria.vo.Member;

public class LoginDAO {

	public LoginDAO() {
		BasicConfigurator.configure();
	}

	Logger logger = Logger.getLogger(LoginDAO.class);

	/**
	 * verifyUser Used to get Verify the Login information
	 * 
	 * @param Member,
	 *            Session
	 * 
	 * @return Member
	 * @throws NGFException
	 */

	public Member verifyUser(Member member, Session session)
			throws NGFException {

		Member memberVo = null;

		try {
			logger.info("Start verifyUser");
			memberVo = (Member) session.createCriteria(Member.class).add(
					Expression.eq("userName", member.getUserName())).add(
					Expression.eq("password", member.getPassword()))
					.uniqueResult();

		} catch (Exception e) {
			System.out.println(e.toString());
			logger.error(e.toString());
			throw new NGFException(e.getMessage());
		}

		return memberVo;
	}
}
